package com.jinly.ryder.schedule;

import com.jinly.ryder.monitor.config.MonitorProperties;
import com.jinly.ryder.monitor.service.MonitorDataCollectService;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class MonitorTask {
    private final MonitorDataCollectService monitorDataCollectService;
    private final MonitorProperties monitorProperties;

    @Scheduled(cron = "${devops.monitor.collect.cron}")
    public void collectAll() {
        if (!monitorProperties.getCollect().isEnable()) return;
        monitorDataCollectService.collectAll();
    }


    @Scheduled(cron = "${devops.monitor.clean.cron}")
    public void cleanData() {
        if (!monitorProperties.getClean().isEnable()) return;
        monitorDataCollectService.cleanData(monitorProperties.getClean().getMaxDay(), monitorProperties.getClean().getBatchSize());
    }


}
